<admintpl file="header" />
<link rel="stylesheet" href="__PUBLIC__/css/simple_upload.css" type="text/css" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Admin/Live/index')}">直播列表</a></li>
			<li><a href="{:U('Admin/Live/add_competition')}">添加赛事直播</a></li>
			<li><a href="{:U('Admin/Live/add_activity')}">添加活动直播</a></li>
			<li class="active"><a>查看赛事直播</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="{:U('Admin/Live/edit_competition_post')}">
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">直播名称：</label>
					<div class="span3">
						<input type="text" name="name" disabled value="{$name}">
					</div>
					<label class="span1 control-label" style="width: 90px;"><nobr>是否VR：</nobr></label>
					<div class="span3">
						<select class="select_2" disabled name="category">
							<option value="1" <if condition="$category eq 1"> checked </if>>否</option>
							<option value="2" <if condition="$category eq 2"> checked </if>>是</option>
						</select>
					</div>
				</div>
				
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">开始时间：</label>
					<div class="span3">
						<input type="text" name="startTime" disabled value="{$startTime/1000|date='Y-m-d H:i', ###}" class="js-datetime" autocomplete="off">
					</div>
					<label class="span1 control-label" style="width: 90px;">结束时间：</label>
					<div class="span3">
						<input type="text" class="js-datetime" disabled value="{$endTime/1000|date='Y-m-d H:i', ###}" name="endTime" autocomplete="off">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">直播频道：</label>
					<div class="span3">
					    <table class="table table-hover table-bordered">
							<tbody>
							<foreach name="selectedChannels" item="vo">
							    <tr>
							    <td>{$vo.channelName}</td>
							    <td><a class="link_url" data-clipboard-text="{$vo.pushUrl}" title="{$vo.pushUrl}" href="javascript:;">复制推流地址</a></td>
								</tr>
							</foreach>
							</tbody>
		               </table>
					</div>
					<label class="span1 control-label" style="width: 90px;">解说员：</label>
					<div class="span3">
						
						<input type="hidden" name="operatorIds" id="operatorIds"/>
						<select multiple="multiple" id="selectedOperatorIds" style="height:150px;">
							<foreach name="selectedCommentators" item="vo">
								<option value="{$vo}" >{$vo}</option>
							</foreach>
						</select>
					</div>
				</div>
				
				<div class="control-group" style="display:none;">
					<label class="span1 control-label" style="width: 90px;">解说员：</label>
					<div class="span3">
						<select multiple="multiple" id="allOperatorIds" style="height:120px;">
						    <foreach name="operatorList" item="vo">
								<option value="{$vo.operatorId}" >{$vo.onickName}({$vo.ouserName})</option>
							</foreach>
						</select>
					</div>
					
				</div>
				
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">A队名称：</label>
					<div class="span3">
						<input type="text" name="teamAName" disabled value="{$teamAName}">
					</div>
					<label class="span1 control-label" style="width: 90px;">B队名称：</label>
					<div class="span3">
						<input type="text" name="teamBName" disabled value="{$teamBName}">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;"><nobr>赛事类型：</nobr></label>
					<div class="span3">
						<select class="select_2" id="typeId" disabled name="typeId">
							<foreach name="types" item="vo">
								<option value="{$vo.typeId}" >{$vo.name}</option>
							</foreach>
						</select>
					</div>
					<label class="span1 control-label" style="width: 90px;">平局赔率：</label>
					<div class="span3">
						<input type="text" name="drawOdds" disabled value="{$drawOdds}">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">A队赔率：</label>
					<div class="span3">
						<input type="text" name="teamAOdds" disabled value="{$teamAOdds}">
					</div>
					<label class="span1 control-label" style="width: 90px;">B队赔率：</label>
					<div class="span3">
						<input type="text" name="teamBOdds" disabled value="{$teamBOdds}">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">A队图标：</label>
					
					<div class="span3 wrapper">
                          <div id="uploader-image">
                              <div id="fileList" class="uploader-list">
                                  <div id="teamAIconDiv" class="file-item thumbnail" style="width:100px;height: 100px;">
                                      <a href="{$teamAIcon}" title="查看原图" target="_blank"><img id="teamAIconPreview" src="{$teamAIcon}" style="width:100px;height: 100px;"></a>
                                  </div>
                              </div>
                          </div>
                    </div>
					<label class="span1 control-label" style="width: 90px;">B队图标：</label>
					<div class="span3 wrapper">
                          <div id="uploader-image">
                              <div id="fileList" class="uploader-list">
                                  <div id="teamBIconDiv" class="file-item thumbnail" style="width:100px;height: 100px;">
                                      <a href="{$teamBIcon}" title="查看原图" target="_blank"><img id="teamBIconPreview" src="{$teamBIcon}" style="width:100px;height: 100px;"></a>
                                  </div>
                              </div>
                          </div>
                    </div>
				</div>
				<div class="control-group">
					<label class="span2 control-label" style="width: 90px;">直播介绍：</label>
					<div class="span7">
						<textarea style="width: 556px; height: 60px;" disabled name="introduction">{$introduction}</textarea>
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">封面图片：</label>
					<div class="span3 wrapper">
                          <div id="uploader-image">
                              <div id="fileList" class="uploader-list">
                                  <div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
                                      <a href="{$imageUrl}" title="查看原图" target="_blank"><img id="imagePreview" src="{$imageUrl}" style="width:150px;height: 150px;"></a>
                                  </div>
                              </div>
                          </div>
                    </div>
                    
				</div>
			<div class="form-actions" style="padding-left:260px;">
			    <input type="hidden" id="broadcastId" name="broadcastId" value="{$broadcastId}"/>
				<if condition="$status eq 1">
			        <a class="btn btn-primary" href='{:U("Admin/Live/edit", array("broadcastId"=>number_format($broadcastId, 0, "", "")))}'>编辑</a>
				</if>
				<if condition="$typeId neq 0">
			   		<if condition="$status eq 3">
				   		<if condition="$vsResult eq null">
				   			<a id="setResult" data-id="{$broadcastId}" href='{:U("Admin/Live/setResult", array("broadcastId"=>number_format($broadcastId, 0, "", "")))}' class="btn btn-primary">胜负设定</a>
				   		</if>
			   		</if>
			    </if>
				&nbsp;&nbsp;<a class="btn" href="{:U('Admin/Live/index')}">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js"></script>
	<script type="text/javascript" >
		
		function setOperatorIds(){
			var ids = [];
			$('#selectedOperatorIds option').each(function(){
				ids.push($(this).val());
			});
			$('#operatorIds').val(ids.join(','));
		}
		
		$('#typeId').val({$typeId});
		$("#selectedChannelIds option").each(function(){
			$('#allChannelIds option[value="'+$(this).val()+'"]').remove();
		});

		$("#selectedOperatorIds option").each(function(){
			$(this).text($('#allOperatorIds option[value="'+$(this).val()+'"]').text());
			$('#allOperatorIds option[value="'+$(this).val()+'"]').remove();
		});
		
		setOperatorIds();
		$(document).ready(function(){
			$('input[name="query_form_btn"]').click(function(){
				 $('#query_form').attr('action', $(this).attr('data-action'));
				 $('#query_form').submit();
			});
			var clip = new ZeroClipboard($("td .link_url"));
			clip.on("aftercopy", function(e){
			    alert('复制成功！');
			});
			
			$('#setResult').click(function(e){
				e.preventDefault();
				$_this = this;
				var broadcastId = $($_this).attr('data-id');
				var teamAName = '';
				var teamBName = '';
				$.getJSON('{:U("Admin/Live/get")}&broadcastId='+broadcastId).done(function (data) {
		            if (data.state === 'success') {
		            	teamAName = data.teamAName;
		            	teamBName = data.teamBName;
		            	var href = $($_this).prop('href');
		    			art.dialog({
		                    title: "赛事胜负结果设定(只能设置一次)",
		                    icon: 'question',
		                    content: '<select id="vsResult"><option value="1">'+teamAName+'(A队)胜</option><option value="2">'+teamBName+'(B队)胜</option><option value="3">平局</option></select>',
		                    close: function () {
		                        $_this.focus(); //关闭时让触发弹窗的元素获取焦点
		                        return true;
		                    },
		                    okVal:"确定",
		                    ok: function () {
		                    	var vsResult = $('#vsResult').val();
		                    	var text = "A队胜";
		                    	if(2 == vsResult){
		                    		text = "B队胜";
		                    	}else if(3 == vsResult){
		                    		text = "平局";
		                    	}
		                    	art.dialog({
		                            title: false,
		                            icon: 'question',
		                            content: '您确定要将比赛结果设定为' + text + '吗？',
		                            close: function () {
		                            	$.getJSON(href+'&vsResult='+vsResult).done(function (data) {
		                                    if (data.state === 'success') {
		                                        if (data.referer) {
		                                            location.href = data.referer;
		                                        } else {
		                                            reloadPage(window);
		                                        }
		                                    } else if (data.state === 'fail') {
		    				    				art.dialog({   
		    				    					content: data.info,
		    				    					icon: 'warning',  
		    				    					ok: function () {   
		    				    						this.title(data.info);   
		    				    						return true;   
		    				    					}
		    				    				}); 
		                                    }
		                                });
		                                return true;
		                            },
		                            okVal:"确定",
		                            ok: function () {
		                            },
		                            cancelVal: '关闭',
		                            cancel: true
		                        });
		                    },
		                    cancelVal: '关闭',
		                    cancel: true
		                });
		            
		            } else if (data.state === 'fail') {
						art.dialog({   
							content: data.info,
							icon: 'warning',  
							ok: function () {   
								this.title(data.info);   
								return true;   
							}
						}); 
		            }
		        });
			});
		});
	</script>
</body>
</html>